package 异常;

import java.util.InputMismatchException;
import java.util.Scanner;

public class Test02 {
    public static void main(String[] args) {
        //计算平均课时:输入总课时和课程数,计算平均课时.要求捕捉输入和除法错误;如果总课时少于100,抛出课时太少的错误
        double avg;
        System.out.println("请输入总课时");
        Scanner input = new Scanner(System.in);
        try {
            int classTime = input.nextInt();
            while (classTime < 100) {
                System.out.println("总课时少于100");
                return;
            }
            System.out.println("请输入课程数");
            int classNum = input.nextInt();
            avg = classTime / classNum;
            System.out.println("平均课时为" + avg);
        } catch (InputMismatchException e) {
            System.out.println("输入的务必是数字");
        }
         catch (ArithmeticException e) {
            System.out.println("课程不可为0");
        } catch (Exception e) {
            System.out.println(e);
        } finally {
            System.out.println("感谢使用");
        }

    }
}
